<html>

<head>
<title>Calculator</title>
</head>

<body>

<form action="" method="post">
<input type ="text" name="query" />
<input type = "submit" value="calculate" />

<?php
if( preg_match('/^[0-9\*\+\-\/ ]{1,}$/', $_POST['query'])
//      && !preg_match('#/0#', $_POST['query'])
//      && !preg_match('--', $_POST['query'])
        ){
        @eval('echo '.$_POST['query'].';');
}
?>

</form>
</body>
</html>